<?php
include  'admin/Util.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">
    <head>
        <?php
        include  'meta.php';
        ?>
        <title><?php echo Constants::$mainHeader ?></title>
        <?php
        include  'headIcon.php';
        ?>
        <link rel="stylesheet" type="text/css" href="media/default.css" media="screen" />
        <link rel="stylesheet" type="text/css" href="lightbox/lightbox.css" media="screen" />
        <script type="text/javascript" src="lightbox/prototype.js"></script>
        <script type="text/javascript" src="lightbox/scriptaculous.js?load=effects"></script>
        <script type="text/javascript" src="lightbox/lightbox.js"></script>
        <!-- TODO: doplnit meta copyright, description, keywords -->
    </head>
    <body>

        <h1><?php echo Constants::$mainHeader ?></h1>

        <?php
        include  'menu.php';
        ?>

        <!-- CONTENTS START -->

        <div id="contents">
            <div class="boxtop"></div>
            <div class="boxhdr"><h2>News archive</h2><div style="float: right; height: 34px; line-height: 34px; margin-right: 15px;"></div></div>
            <div class="boxtxt">

                <?php

                $link = Util::getLink();

                $query = sprintf(Util::$select_jornakDestination,
                    mysql_real_escape_string("1")
                );

                $result = mysql_query($query);

                if (!$result) {
                    die('Could not query:' . mysql_error());
                }

                $i = 0;
                while ($row = mysql_fetch_assoc($result)) {
                    $i++;
                    //if ($i == 4) break;
                    $textID[$i] = $row['textid'];
                    $time[$i] = $row['time'];
                }
                $count = count($textID);
                for ($i = 1; $i < $count+1; $i++) {
                    if ($textID[$i] == null) break;
                    $query = sprintf(Util::$select_jornakText,
                        mysql_real_escape_string($textID[$i])
                    );

                    $result = mysql_query($query);

                    if (!$result) {
                        die('Could not query:' . mysql_error());
                    }

                    while ($row = mysql_fetch_assoc($result)) {
                        echo "<h3>".stripslashes($row['header'])."</h3>";
                        echo '<p class="date">'.Util::parseDateTime($time[$i])."</p>";
                        echo "<p>".stripslashes($row['text']).'<br><br>';
                        include 'fbLike.php';
                        echo "</p>";
                        if ($i < $count) {echo "<hr />";}else { echo '<br>';};
                    }
                }

                Util::closeLink($link);

                ?>
                <div id="cleaner"></div>
            </div>
            <div class="boxbtm"></div>
        </div>

        <!-- CONTENTS END -->

        <?php
        include  'footer.php';
        ?>

    </body>
</html>